package Task20;

import java.util.Scanner;

/**
 * 动态规划公共子串计算
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.next();
        String str2 = scanner.next();
        if(str1.length() < str2.length()){
            System.out.println(getsublen(str1,str2));
        }else{
            System.out.println(getsublen(str2,str1));
        }
    }
    public static int getsublen(String str1,String str2){
        char[] ch1 = str1.toCharArray();
        char[] ch2 = str2.toCharArray();
        int[][] getlen = new int[ch1.length + 1][ch2.length + 1];
        int maxlen = 0;
        for(int i = 1; i <=ch1.length; i++){
            for(int j = 1; j <= ch2.length;j++){
                if(ch1[i - 1] == ch2[j - 1]){
                    getlen[i][j] = getlen[i-1][j-1] + 1;
                    if(maxlen < getlen[i][j]){
                        maxlen = getlen[i][j];
                    }
                }
            }
        }
        return maxlen;
    }
}
